package com.sphd.restaurantsystem.presenter;


import android.util.Log;

import com.android.volley.VolleyError;
import com.sphd.restaurantsystem.info.GreensInfo;
import com.sphd.restaurantsystem.info.SortInfo;
import com.sphd.restaurantsystem.info.VipInfo;
import com.sphd.restaurantsystem.model.WaiterModelImpl;
import com.sphd.restaurantsystem.view.WaiterView;

import java.util.List;

/**
 * Created by Hu on 2016/11/22
 */

public class WaiterPresenterImpl implements WaiterPresenter {
    WaiterModelImpl waiterModel;
    WaiterView waiterView;

    public WaiterPresenterImpl(WaiterView waiterView) {
        this.waiterView = waiterView;
        waiterModel = new WaiterModelImpl();
    }

    @Override
    public void addData(String url) {
        waiterView.showLoading();
        waiterModel.sendUrl(url,this);
    }

    @Override
    public void sendError(VolleyError error) {
        waiterView.dissLoading();
    }

    @Override
    public void senRes(List<SortInfo> sortInfos, List<GreensInfo> greensInfos) {
        waiterView.recRes(sortInfos,greensInfos);
        waiterView.dissLoading();
    }

    @Override
    public void getUserDate(String url) {
        waiterView.showLoading();
        waiterModel.sendUserurl(url,this);
    }

    @Override
    public void sendUerError() {
        waiterView.dissLoading();
        Log.e("sendUerError","sendUerError");
    }

    @Override
    public void sendUer(List<VipInfo> vipInfos) {
        waiterView.recUer(vipInfos.get(0));
        waiterView.dissLoading();
    }
}